#include <stdio.h>


void show_array(int arr[], int n)
{
    int i = 0;
    for(i = 0; i < n; i++) {
        printf("%d ", arr[i]);
    }
    printf("\n");

    return;
}

void bubble_sort(int arr[], int n)
{
    int i = 0;
    int j = 0;
    int temp  = 0;
    
    for(i= 0; i < n; i++) {
        for (j = 0; j < n-i-1; j++) {
            if (arr[j] > arr[j+1]) {
                temp = arr[j];
                arr[j] = arr[j+1];
                arr[j+1] = temp;
            }
        }
    }

    return;
}

int main()
{
    int arr[] = {87, 23, 56, 91, 34, 77, 12, 45, 68, 29, 83, 51, 74, 38, 96};
    int n = sizeof(arr)/sizeof(arr[0]);

    printf("Before sort: ");
    show_array(arr, n);

    bubble_sort(arr, n);

    printf("After sort: ");
    show_array(arr, n);
    return 0;
}